package dao.factory;

import dao.BookDao;
import dao.OrderDao;
import dao.UserDao;
import dao.impl.BookDaoImpl;
import dao.impl.OrderDaoImpl;
import dao.impl.UserDaoImpl;

public class DaoFactory {
	
	private static UserDao userDao;
	
	private static BookDao bookDao;
	
	private static OrderDao orderDao;
	
	public static UserDao getInstance(){
		if (userDao==null) {
			synchronized (DaoFactory.class) {
				if (userDao==null) {
					userDao = new UserDaoImpl();
				}
			}
		}
		return userDao;
	}
	
	public static BookDao getBookDaoInstance(){
		if (bookDao==null) {
			synchronized (DaoFactory.class) {
				if (bookDao==null) {
					bookDao = new BookDaoImpl();
				}
			}
		}
		return bookDao;
	}
	
	public static OrderDao getOrderDaoInstance(){
		if (orderDao==null) {
			synchronized (DaoFactory.class) {
				if (orderDao==null) {
					orderDao = new OrderDaoImpl();
				}
			}
		}
		return orderDao;
	}

}
